#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int m,n;
    int a[10][10];
    cin >> m >> n;
    struct singer
    {
        int no;
        int score;
    };
    singer s[10];
    for(int i =  0; i<m; i++)
    {
        int max = 0;
        int min  = 100;
        int sum = 0;
        for(int j = 0; j<n; j++)
        {
            int temp = 0;
            cin >> temp;
            sum = sum + temp;
            if(temp < min )
                min = temp;
            if(temp > max)
                max = temp;
        }
        s[i].no = i+1;
        s[i].score = sum - max - min;
            
    }
    while(true)
    {
        bool ifSwap = false;
        for(int i = 0; i<m-1; i++)
        {
            if(s[i].score < s[i+1].score)
            {
                ifSwap = true;
                singer ts = s[i];
                s[i] = s[i+1];
                s[i+1] =ts ;
            }
        }
        if(ifSwap == false)
            break;
    }
    
    for(int i =  0; i<m; i++)
    {
        cout << setw(3) <<s[i].no;
    }
    
    /*
    int (* p)[10] = a;
    for(int i =  0; i<m; i++)
    {
        for(int j = 0; j<n; j++)
        {
            //cout  << p[i][j] <<" ";
            cout  << *(*(p+i)+j) << " ";
        }
        cout << endl;
    }
    */
    
    
}